package com.ruoyi.warehouse.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.warehouse.domain.WWarehouseFeeAccount;
import com.ruoyi.warehouse.service.IWWarehouseFeeAccountService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 仓储记账Controller
 * 
 * @author wzy
 * @date 2024-08-28 11:25:24
 */
@RestController
@RequestMapping("/warehouses/account")
public class WWarehouseFeeAccountController extends BaseController
{
    @Autowired
    private IWWarehouseFeeAccountService wWarehouseFeeAccountService;

    /**
     * 查询仓储记账列表
     */
    @PreAuthorize("@ss.hasPermi('warehouses:account:list')")
    @GetMapping("/list")
    public TableDataInfo list(WWarehouseFeeAccount wWarehouseFeeAccount)
    {
        startPage();
        List<WWarehouseFeeAccount> list = wWarehouseFeeAccountService.selectWWarehouseFeeAccountList(wWarehouseFeeAccount);
        return getDataTable(list);
    }

    /**
     * 导出仓储记账列表
     */
    @PreAuthorize("@ss.hasPermi('warehouses:account:export')")
    @Log(title = "仓储记账", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WWarehouseFeeAccount wWarehouseFeeAccount)
    {
        List<WWarehouseFeeAccount> list = wWarehouseFeeAccountService.selectWWarehouseFeeAccountList(wWarehouseFeeAccount);
        ExcelUtil<WWarehouseFeeAccount> util = new ExcelUtil<WWarehouseFeeAccount>(WWarehouseFeeAccount.class);
        util.exportExcel(response, list, "仓储记账数据");
    }

    /**
     * 获取仓储记账详细信息
     */
    @PreAuthorize("@ss.hasPermi('warehouses:account:query')")
    @GetMapping(value = "/{warehouseFeeAccountId}")
    public AjaxResult getInfo(@PathVariable("warehouseFeeAccountId") Long warehouseFeeAccountId)
    {
        return success(wWarehouseFeeAccountService.selectWWarehouseFeeAccountByWarehouseFeeAccountId(warehouseFeeAccountId));
    }

    /**
     * 新增仓储记账
     */
    @PreAuthorize("@ss.hasPermi('warehouses:account:add')")
    @Log(title = "仓储记账", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WWarehouseFeeAccount wWarehouseFeeAccount)
    {
        wWarehouseFeeAccount.setCreateBy(getNickName());
        return toAjax(wWarehouseFeeAccountService.insertWWarehouseFeeAccount(wWarehouseFeeAccount));
    }

    /**
     * 修改仓储记账
     */
    @PreAuthorize("@ss.hasPermi('warehouses:account:edit')")
    @Log(title = "仓储记账", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WWarehouseFeeAccount wWarehouseFeeAccount)
    {
        wWarehouseFeeAccount.setUpdateBy(getNickName());
        return toAjax(wWarehouseFeeAccountService.updateWWarehouseFeeAccount(wWarehouseFeeAccount));
    }

    /**
     * 删除仓储记账
     */
    @PreAuthorize("@ss.hasPermi('warehouses:account:remove')")
    @Log(title = "仓储记账", businessType = BusinessType.DELETE)
	@DeleteMapping("/{warehouseFeeAccountIds}")
    public AjaxResult remove(@PathVariable Long[] warehouseFeeAccountIds)
    {
        return toAjax(wWarehouseFeeAccountService.deleteWWarehouseFeeAccountByWarehouseFeeAccountIds(warehouseFeeAccountIds));
    }
}
